import page
from base.app_base import AppBase
from time import sleep

from tools.get_log import GetLog

logger = GetLog.get_logger()


class PageAppCsdnLogin(AppBase):
    # 1.CSDN进入首页，点击我的
    def page_click_my(self):
        sleep(5)
        self.base_click(page.csdn_my_button)
    # 2.点击圆形登录
    def page_click_cycle_login(self):
        sleep(1)
        self.base_click(page.csdn_round_login_button)

    # 3.选择账号登录
    def page_choose_account_login(self):
        sleep(1)
        self.base_click(page.csdn_account_login_button)

    # 4.输入账号
    def page_input_account(self, phone):
        sleep(0.5)
        self.base_input(page.csdn_phone_button, phone)

    # 5.输入密码
    def page_input_password(self, pwd):
        sleep(0.5)
        self.base_input(page.csdn_pwd_button, pwd)

    # 6.点击同意条款
    def page_agree_terms(self):
        sleep(1)
        self.base_click(page.csdn_agree_button)

    # 7.点击登录
    def page_click_login(self):
        sleep(1)
        self.base_click(page.csdn_login_button)

    # 8.判断页面是否存在用户名
    def page_get_account_name(self):
        sleep(3)
        return self.base_get_text(page.csdn_account_name)

    # 9.组合业务登录方法
    def page_app_csdn_login(self, phone, pwd):
        logger.info('正在调用app应用登录业务方法 手机号:{},密码:{}'.format(phone, pwd))
        self.page_click_my()
        self.page_click_cycle_login()
        self.page_choose_account_login()
        self.page_input_account(phone)
        self.page_input_password(pwd)
        self.page_agree_terms()
        self.page_click_login()





